package main.model.hexisland.location;

/**
 * Created with IntelliJ IDEA.
 * User: gabe
 * Date: 14/06/13
 * Time: 20:41
 * To change this template use File | Settings | File Templates.
 */
public class SubHexLocation extends HexLocation {

    private int sector;

    public SubHexLocation(int x, int y, int z, int sector) {
        super(x, y, z);
        this.sector = sector;
    }

    public SubHexLocation(int q, int r, int sector) {
        super(q, r);
        this.sector = sector;
    }

    public SubHexLocation(HexLocation hexLocation, int sector) {
        super(hexLocation);
        this.sector = sector;
    }

    public SubHexLocation(SubHexLocation subHexLocation) {
        super(subHexLocation);
        this.sector = subHexLocation.getSector();
    }

    public int getSector(){
        return sector;
    }

    @Override
    public boolean equals(Object obj) {
        if ( this == obj ) return true;
        if (obj instanceof SubHexLocation){
            SubHexLocation hexLocation = (SubHexLocation)obj;
            if(hexLocation.getQ() == this.getQ()
                    && hexLocation.getR() == this.getR()
                    && hexLocation.getSector() == this.getSector()){
                return true;
            }
        }
        else if (obj instanceof HexLocation){
            HexLocation hexLocation = (HexLocation)obj;
            if(hexLocation.getQ() == this.getQ()
                    && hexLocation.getR() == this.getR()){
                return true;
            }
        }
        return false;
    }

    @Override
    public int hashCode() {
        int hashCode = 3;
        hashCode = 5  * hashCode + super.getQ();
        hashCode = 13 * hashCode + super.getR();
        hashCode = 3 * hashCode + sector ;
        return hashCode;
    }


    @Override
    public String toString() {
        return "Q:"+super.getQ()+",R:"+super.getR()+",S:"+getSector();    //To change body of overridden methods use File | Settings | File Templates.
    }

}
